--[[
    模拟银监会动态检测指标
-- ]]
require "apm_core"
local ApmExt = require("ApmExt")

local t_yjh_stability = {
    {
        level1 = "核心业务系统",
        level2 = { "资金变动类", "非资金变动类" }
    },
    {
        level1 = "综合前置系统",
        level2 = { "大小额支付前置系统", "ATM前置系统", "银联前置系统", "超级网银前置系统", "POS渠道", "第三方存管前置系统" }
    },
    {
        level1 = "信用卡系统",
        level2 = { "电话银行渠道", "手机银行渠道", "ATM渠道", "POS渠道" }
    },
    {
        level1 = "网上银行系统",
        level2 = { "个人网银", "企业网银" }
    },
    {
        level1 = "电话银行系统",
    },
    {
        level1 = "手机银行",
    },
}

local t_yjh_scale = {
    "网上银行",
    "电话银行",
    "手机银行",
    "ATM",
    "POS"
}

-- return 1: 该数据不上报;其它:上报数据
function post_analysis()
    local ApmData = require("ApmData")
    if ApmData.getMsgType() ~= 1 then return end

    local yjh_stability_level1_idx = ApmExt.getMicroSecond() % #t_yjh_stability + 1
    local yjh_stability_level1 = t_yjh_stability[yjh_stability_level1_idx].level1
    local t_yjh_stability_level2 = t_yjh_stability[yjh_stability_level1_idx].level2
    local yjh_stability_level2
    if type(t_yjh_stability_level2) == "table" then
        yjh_stability_level2 = t_yjh_stability_level2[ApmExt.getMicroSecond() % #t_yjh_stability_level2 + 1]
    end

    local yjh_scale_level1 = t_yjh_scale[ApmExt.getMicroSecond() % #t_yjh_scale + 1]

    ApmData.replaceField("transaction.yjh.stability.level1", yjh_stability_level1)
    ApmData.replaceField("transaction.yjh.stability.level2", yjh_stability_level2)
    ApmData.replaceField("transaction.yjh.scale.level1", yjh_scale_level1)

    logInfo("level1:[%s] level2:[%s] scale:[%s]", yjh_stability_level1, yjh_stability_level2, yjh_scale_level1)

    return
end
